package com.spring.cootask.web.controller;

import com.spring.cootask.web.model.FeTaskTablebaseDetailSys;
import com.spring.cootask.web.service.SysColumnService;
import com.spring.security.web.model.BaseResult;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import java.util.List;

/**
 * Created by WoJunyu on 2016/10/8.
 */
@Controller
@RequestMapping(value = "/syscolumn")
public class SysColumnController {

    static Logger logger = Logger.getLogger(SysColumnController.class
            .getName());

    @Resource
    private SysColumnService sysColumnService;


    @RequestMapping(value = "/index")
    public ModelAndView index(Model model,HttpServletRequest request){
//        ShopOaSessionUtil.OaUser oaUser = ShopOaSessionUtil.getOaUser(request);
//        model.addAttribute("deptId",oaUser.getUser_shopdept_id());
        return new ModelAndView("main/fetask/task/syscolumn");
    }


    @RequestMapping(value = "/queryDataList")
    @ResponseBody
    public Object queryDataList(FeTaskTablebaseDetailSys data,HttpServletRequest request) {
//        ShopOaSessionUtil.OaUser oaUser = ShopOaSessionUtil.getOaUser(request);
//        //用户未登录
//        if(oaUser!=null&&!ApplicationUtils.isNotNull(oaUser.getOa_user_id())){
//            return null;
//        }
        System.out.println(logger.isDebugEnabled()+"------->");
        List<FeTaskTablebaseDetailSys> list = null;
        try{
            list = sysColumnService.selectByPrimaryParm(data);
        }catch(Exception e){
            e.printStackTrace();
        }
        return list;
    }
    
    @RequestMapping(value = "/sysColumn" ,method = RequestMethod.POST)
    @ResponseBody
    public Object sysColumn(@RequestBody FeTaskTablebaseDetailSys feTaskTablebaseDetailSys,HttpServletRequest request) {
       
    	BaseResult baseResult = null;
        try{
        	baseResult = sysColumnService.saveOrUpdateSysColumn(feTaskTablebaseDetailSys);
        }catch(Exception e){
            e.printStackTrace();
            baseResult=new BaseResult("0","系统异常");
        }
        return baseResult;
    }
    
    @RequestMapping(value = "/delSysColumn" ,method = RequestMethod.POST)
    @ResponseBody
    public Object sysColumn(String id,HttpServletRequest request) {
       
    	BaseResult baseResult = null;
        try{
        	baseResult = sysColumnService.delSysColumn(id);
        }catch(Exception e){
            e.printStackTrace();
            baseResult=new BaseResult("0","系统异常");
        }
        return baseResult;
    }
    
    
    
}
